<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<%@ include file="/WEB-INF/views/include/head.jsp"%>
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#weiXiuForm").validate();

				var flag = "${obj.flag}";
				if (flag == 'edit') {
					$("#weiXiuForm").attr("action", "${ctx}/WeiXiu/update");
				}

				$("#gouMaiRiQi")
						.datepicker(
								{
									changeMonth : true, //月选项
									changeYear : true, //年选项
									dateFormat : "yy-mm-dd", //时间格式
									showButtonPanel : true, //显示面板底部按钮
									closeTextType : "关闭", //关闭按钮文字
									currentText : "今天", //返回今天按钮文字
									dayNamesMin : [ '天', '一', '二', '三', '四',
											'五', '六' ], //星期   
									monthNamesShort : [ '1', '2', '3', '4',
											'5', '6', '7', '8', '9', '10',
											'11', '12' ]
								//月份显示
								});
			});

	//添加行
	function add() {
		var a = $("#wuliao>tbody").children("tr").length - 1;
		var currentRow = $("#wuliao>tbody").children("tr").eq(a);
		var tr = "<tr><td><input type=\"text\" name=\"weixiu.wuLiaos["+a+"].wuLiaoDanHao\" class=\"text required\"/></td><td><input type=\"text\" name=\"weixiu.wuLiaos["+a+"].peiJianMing\" class=\"text required\"/></td><td><input type=\"text\" name=\"weixiu.wuLiaos["+a+"].wuLiaoBianHao\" class=\"text required\"/></td><td><input type=\"text\" name=\"weixiu.wuLiaos["+a+"].shuLiang\" class=\"text required\"/></td></tr>";
		currentRow.after(tr);
		$("#wuliao").append(currentRow);
		
	}

	//删除行
	function dell() {
		var a = $("#wuliao>tbody").children("tr").length - 2;
		if (a > 1) {
			$("#wuliao>tbody").children("tr").eq(a).remove();
		}
	}
</script>
</head>
<body class="ContentBody">
	<form action="${ctx}/WeiXiu/save" method="post" id="weiXiuForm"
		enctype="multipart/form-data">
		<input type="hidden" name="weixiu.weiXiuId"
			value="${obj.weixiu.weiXiuId }" /> <input type="hidden"
			name="weixiu.dingDanHao" value="${obj.weixiu.dingDanHao }" /> <input
			type="hidden" name="weixiu.luRuRen" value="${obj.weixiu.luRuRen }" />
		<input type="hidden" name="weixiu.tuPian1"
			value="${obj.weixiu.tuPian1 }" /> <input type="hidden"
			name="weixiu.tuPian2" value="${obj.weixiu.tuPian2 }" /> <input
			type="hidden" name="weixiu.tuPian3" value="${obj.weixiu.tuPian3 }" />
		<input name="weixiu.baoXiuRiQi" id="baoXiuRiQi" type="hidden"
			value="<fmt:formatDate value="${obj.weixiu.baoXiuRiQi}" pattern="yyyy-MM-dd"/>" />
		<tr>
			<td height="30">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td height="62" background="${ctxStatic}/images/nav04.gif">
							<!--  -->
							<table width="98%" border="0" align="center" cellpadding="0"
								cellspacing="0">
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<div class="MainDiv">
			<table width="99%" border="0" cellpadding="0" cellspacing="0"
				class="CContent">
				<tr>
					<th class="tablestyle_title">添加维修单页面</th>
				</tr>
				<tr>
					<td class="CPanel">
				<TR>
					<TD width="100%">
						<fieldset style="height: 100%;">
							<legend>添加维修单</legend>
							<table border="0" cellpadding="2" cellspacing="1"
								style="width: 100%">
								<tr>
									<td nowrap align="right" width="13%">维修人员:</td>
									<td width="41%"><select class="required"
										name="weixiu.weiXiuRen" id="weiXiuRen">
											<option value="">---请选择---</option>
											<c:forEach items="${obj.shiFus}" var="shifu">
												<option value="${shifu.shiFuName}"
													<c:if test="${ obj.weixiu.weiXiuRen == shifu.shiFuName}">selected="selected"</c:if>>${shifu.shiFuName}</option>
											</c:forEach>
									</select></td>
									<td align="right" width="19%">品牌名:</td>
									<td width="27%"><select class="required"
										name="weixiu.pingPaiHao" id="pingPaiHao">
											<option value="">---请选择---</option>
											<c:forEach items="${obj.pingPais}" var="pingpai">
												<option value="${pingpai.pingPaiName}"
													<c:if test="${ obj.weixiu.pingPaiHao == pingpai.pingPaiName}">selected="selected"</c:if>>${pingpai.pingPaiName}</option>
											</c:forEach>
									</select></td>
								</tr>
								<tr>
									<td nowrap align="right" width="13%">用户地址:</td>
									<td width="41%"><input id="yongHuDiZhi"
										name="weixiu.yongHuDiZhi" class="text required" type="text"
										value="${obj.weixiu.yongHuDiZhi}" /></td>
									<td nowrap align="right" width="13%">品牌型号:</td>
									<td width="27%"><input name="weixiu.pingPaiXingHao"
										id="pingPaiXingHao" class="text" type="text"
										value="${obj.weixiu.pingPaiXingHao}" /></td>
								</tr>
								<tr>
									<td nowrap align="right" width="13%">用户电话:</td>
									<td width="41%"><input id="yongHuPhone"
										name="weixiu.yongHuPhone" class="text required" type="text"
										value="${obj.weixiu.yongHuPhone}" /></td>
									<td align="right" width="19%">购买日期:</td>
									<td width="27%"><input name="weixiu.gouMaiRiQi"
										id="gouMaiRiQi" readonly="readonly" type="text"
										value="<fmt:formatDate value="${obj.weixiu.gouMaiRiQi}" pattern="yyyy-MM-dd"/>" /></td>
								</tr>
								<tr>
									<td align="right" width="19%">用户姓名:</td>
									<td width="41%"><input id="yongHuName"
										name="weixiu.yongHuName" class="text required" type="text"
										value="${obj.weixiu.yongHuName}" /></td>
									<td align="right" width="19%">内机条码:</td>
									<td width="27%"><input name="weixiu.tiaoMa" id="tiaoMa"
										class="text" type="text" style="width: 240px;"
										value="${obj.weixiu.tiaoMa}" /></td>
								</tr>
								<tr>
									<td nowrap align="right" width="13%">是否维修:</td>
									<td width="41%"><input name="weixiu.zhuangTai"
										class="text required" type="radio" value="1" checked="checked" />未维修&nbsp;&nbsp;&nbsp;&nbsp;<input
										name="weixiu.zhuangTai" class="text required" type="radio"
										value="2"
										<c:if test="${ obj.weixiu.zhuangTai == 2}">checked="checked"</c:if> />已维修</td>
									<td nowrap align="right" width="13%">外机条码:</td>
									<td width="27%"><input name="weixiu.waiJiTiaoMa"
										id="waiJiTiaoMa" class="text" style="width: 240px;"
										type="text" value="${obj.weixiu.waiJiTiaoMa}" /></td>
								</tr>
								<tr>
									<td nowrap align="right" width="13%">保修类型:</td>
									<td width="41%"><input name="weixiu.baoXiuLeiXing"
										class="text required" type="radio" value="1" checked="checked" />保修内&nbsp;&nbsp;&nbsp;&nbsp;<input
										name="weixiu.baoXiuLeiXing" class="text required" type="radio"
										value="2"
										<c:if test="${ obj.weixiu.baoXiuLeiXing == 2}">checked="checked"</c:if> />保修外</td>
									<td nowrap align="right" width="13%">图片1:</td>
									<td width="27%"><input name="file" type="file" /></td>
								</tr>
								<tr>
									<td nowrap align="right" width="13%">拉修费用:</td>
									<td width="41%"><input id="laXiuFeiYong"
										name="weixiu.laXiuFeiYong" class="text number" type="text" /></td>
									<td align="right" width="19%">图片2:</td>
									<td width="27%"><input name="file" type="file" /></td>
								</tr>
								<tr>
									<td align="right" width="19%">维修费用:</td>
									<td width="41%"><input id="weiXiuFei"
										name="weixiu.weiXiuFei" class="text number" type="text" /></td>
									<td align="right" width="19%">图片3:</td>
									<td width="27%"><input name="file" type="file" /></td>
								</tr>
								<tr>
									<td nowrap align="right" width="13%">故障原因:</td>
									<td width="41%"><textarea rows="5"
											name="weixiu.guZhangYuanYin">${obj.weixiu.guZhangYuanYin}</textarea>
									</td>
									<td align="right" width="19%">维修措施:</td>
									<td width="27%"><textarea rows="5"
											name="weixiu.weiXiuCuoShi">${obj.weixiu.weiXiuCuoShi}</textarea>
									</td>
								</tr>
								<tr>
									<td colspan="4" align="center"><font color="red" id="mima"></font></td>
								</tr>
							</table>
							<br />
							
								<table width="65%" border="0.5" id="wuliao"
									style="margin: auto;">
									<tr class="CTitle">
										<td height="22" colspan="4" align="center"
											style="font-size: 16px">配件列表</td>
									</tr>

									<tr bgcolor="#EEEEEE">
										<td width="25%" align="center">物料单号</td>
										<td width="25%" align="center">配件名称</td>
										<td width="25%" align="center">物料号</td>
										<td width="25%" align="center">数量</td>
									</tr>
									<c:if test="${obj.weixiu.wuLiaos.size() ne 0}">
									<c:forEach items="${obj.weixiu.wuLiaos}" var="wuLiao"
										varStatus="status">
										<input type="hidden"
											name="weixiu.wuLiaos[${status.index}].wuLiaoId"
											value="${wuLiao.wuLiaoId}"/>
											<input type="hidden"
											name="weixiu.wuLiaos[${status.index}].weiXiuDanId"
											value="${wuLiao.weiXiuDanId}"/>
										<tr>
										<td><input type="text"
											name="weixiu.wuLiaos[${status.index}].wuLiaoDanHao"
											value="${wuLiao.wuLiaoDanHao}" class="text required" /></td>
										<td><input type="text"
											name="weixiu.wuLiaos[${status.index}].peiJianMing"
											value="${wuLiao.peiJianMing}" class="text required" /></td>
										<td><input type="text"
											name="weixiu.wuLiaos[${status.index}].wuLiaoBianHao"
											value="${wuLiao.wuLiaoBianHao}" class="text required" /></td>
										<td><input type="text"
											name="weixiu.wuLiaos[${status.index}].shuLiang"
											value="${wuLiao.shuLiang}" class="text required" /></td>
											</tr>
									</c:forEach>
									</c:if>


									<tr>
										<td></td>
										<td></td>
										<td align="right"><input type="button" onclick="add()"
											value="新增" /> &nbsp;&nbsp;&nbsp;&nbsp; <input type="button"
											onclick="dell()" value="删除" /></td>
									</tr>
								</table>
							
						</fieldset>
					</TD>
				</TR>
				</td>
				</tr>
				<TR>
					<TD colspan="2" align="center" height="50px"><input
						type="submit" name="Submit" value="保存" class="button" /> <input
						type="button" name="Submit2" value="返回" class="button"
						onclick="window.history.go(-1);" /></TD>
				</TR>
			</TABLE>
			</td>
			</tr>
			</table>
		</div>
	</form>
</body>
</html>
